{% extends base %}

<!--
    @since 2017/09/14
    @modified 2018/12/09 14:22:26
-->

{% block head %}
    <style type="text/css">
        .sys-cmd-no {
            width: 10%;
            max-width: 100px;
        }
        .sys-cmd {
            width: 70%;
        }
        .category {
            background: #ccf;
            padding: 5px;
        }
        .item {
            width: 20%;
            height: 25px;
            line-height: 25px;
            float: left;
        }

        @media screen and (max-width: 700px) {
            /** mobile **/
            .item {
                width: 50%;
            }
        }

    </style>
{% end %}

{% block body %}

{% for category in xconfig.MENU_LIST %}
    {% if category.need_login and not _has_login %}
        {% continue %}
    {% end %}
    {% if category.need_admin and not _is_admin %}
        {% continue %}
    {% end %}
    <div class="col-md-12 bottom-offset-1 grid-card">
        <div class="grid-title">{{category.name}}</div>
        <div class="col-md-12">
            {% for link in category.children %}
            <div class="item">
                <a href="{{link.url}}">{{link.name}}</a>
            </div>
            {% end %}
        </div>
    </div>
{% end %}

{% if _has_login %}
<div class="col-md-12 grid-card">
    <div class="grid-title">
        常用链接
        <a href="/system/storage?key=tools" class="float-right link">编辑</a>
    </div>
    <div class="col-md-12">
        {% for link in customized_items %}
        <div class="item">
            <a href="{{link.link}}">{{link.name}}</a>
        </div>
        {% end %}
    </div>
    
</div>

<div class="grid-card">
    <div class="col-md-12">
        <span class="currentTime"></span>
        <span class="float-right">
            用户: {{_user_name}}
            <a href="/logout">登出</a>
        </span>
    </div>
</div>
{% end %}


<script type="text/javascript">
$(function () {
    function updateTime () {
        $(".currentTime").html(new Date().format("yyyy-MM-dd HH:mm:ss"));
        setTimeout(updateTime, 1000);
    }
    updateTime();
})


function runCommand(path) {
    // alert("runCommand "+ path);
    $.get("/system/command", {path: path}, function(data, status) {
        alert(data);
    })
}


</script>
{% end %}

{% block aside %}
<div class="aside-item">
    <div class="aside-title">
        用户信息
    </div>
    <div class="aside-content">
        <ul>
        {% if _has_login %}
            <li>时间: <span class="currentTime"></span></li>
            <li>用户: {{_user_name}}</li>
            <li><a href="/logout">登出</a></li>
        {% else %}
            <li><a href="/login">登陆</a></li>
        {% end %}
        </ul>
    </div>
</div>
{% end %}